//
//  LZSHeaderCell.m
//  IOSProject
//
//  Created by lzs on 2018/4/25.
//  Copyright © 2018年 com.linzhisheng. All rights reserved.
//

#import "LZSHeaderCell.h"


@interface LZSHeaderCell()
@property (nonatomic, strong) UILabel *nameTextLabel;
@property (nonatomic, strong) UILabel *noTextLabel;
@property (nonatomic, strong) UILabel *dateTextLabel;
@property (nonatomic, strong) UILabel *realResTextLabel;
@property (nonatomic, strong) UILabel *lotteryResTextLabel;
@property (nonatomic, strong) UILabel *inMoneyTextLabel;
@property (nonatomic, strong) UILabel *redTextLabel;
@property (nonatomic, strong) UILabel *blueTextLabel;
@property (nonatomic, strong) UILabel *hitRedTextLabel;
@property (nonatomic, strong) UILabel *hitBlueTextLabel;
@property (nonatomic, strong) UILabel *isTextLabel;
@property (nonatomic, strong) UILabel *msgTextLabel;
@end

@implementation LZSHeaderCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        //
        UILabel *nameLabel = [self setuplabelwithfont:[UIFont systemFontOfSize:12] withText:@"彩票号码:" withColor:[UIColor lightGrayColor] wihtAlignemt:NSTextAlignmentLeft];
       self.nameTextLabel = [self setuplabelwithfont:[UIFont systemFontOfSize:12] withText:@"number" withColor:[UIColor lightGrayColor] wihtAlignemt:NSTextAlignmentLeft];
        
        //
        UILabel *noLabel = [self setuplabelwithfont:[UIFont systemFontOfSize:12] withText:@"彩票剩余号码:" withColor:[UIColor lightGrayColor] wihtAlignemt:NSTextAlignmentLeft];
        self.noTextLabel = [self setuplabelwithfont:[UIFont systemFontOfSize:12] withText:@"refernumber" withColor:[UIColor lightGrayColor] wihtAlignemt:NSTextAlignmentLeft];
        
        //
        UILabel *dateLabel = [self setuplabelwithfont:[UIFont systemFontOfSize:12] withText:@"期号:" withColor:[UIColor lightGrayColor] wihtAlignemt:NSTextAlignmentLeft];
        self.dateTextLabel = [self setuplabelwithfont:[UIFont systemFontOfSize:12] withText:@"issueno" withColor:[UIColor lightGrayColor] wihtAlignemt:NSTextAlignmentLeft];
        
        UILabel *realRestLabel = [self setuplabelwithfont:[UIFont systemFontOfSize:12] withText:@"中奖状态:" withColor:[UIColor lightGrayColor] wihtAlignemt:NSTextAlignmentLeft];
        self.realResTextLabel = [self setuplabelwithfont:[UIFont systemFontOfSize:12] withText:@"winstatus" withColor:[UIColor lightGrayColor] wihtAlignemt:NSTextAlignmentLeft];
        
        UILabel *lotteryRestLabel = [self setuplabelwithfont:[UIFont systemFontOfSize:12] withText:@"奖项名称:" withColor:[UIColor lightGrayColor] wihtAlignemt:NSTextAlignmentLeft];
        lotteryRestLabel.preferredMaxLayoutWidth = 60;
        self.lotteryResTextLabel = [self setuplabelwithfont:[UIFont systemFontOfSize:12] withText:@"prizename" withColor:[UIColor lightGrayColor] wihtAlignemt:NSTextAlignmentLeft];
        self.lotteryResTextLabel.preferredMaxLayoutWidth = 60;
        
        UILabel *inMoneyLabel = [self setuplabelwithfont:[UIFont systemFontOfSize:12] withText:@"奖项条件:" withColor:[UIColor lightGrayColor] wihtAlignemt:NSTextAlignmentLeft];
        inMoneyLabel.preferredMaxLayoutWidth = 60;
        self.inMoneyTextLabel = [self setuplabelwithfont:[UIFont systemFontOfSize:12] withText:@"require" withColor:[UIColor lightGrayColor] wihtAlignemt:NSTextAlignmentLeft];
        self.inMoneyTextLabel.preferredMaxLayoutWidth = 60;
        
        UILabel *redLabel = [self setuplabelwithfont:[UIFont systemFontOfSize:12] withText:@"单注奖金:" withColor:[UIColor lightGrayColor] wihtAlignemt:NSTextAlignmentLeft];
         redLabel.preferredMaxLayoutWidth = 60;
        self.redTextLabel = [self setuplabelwithfont:[UIFont systemFontOfSize:12] withText:@"singlebonus" withColor:[UIColor lightGrayColor] wihtAlignemt:NSTextAlignmentLeft];
         self.redTextLabel.preferredMaxLayoutWidth = 60;
        
        UILabel *blueLabel = [self setuplabelwithfont:[UIFont systemFontOfSize:12] withText:@"当期中奖号码 红球:" withColor:[UIColor lightGrayColor] wihtAlignemt:NSTextAlignmentLeft];
        self.blueTextLabel = [self setuplabelwithfont:[UIFont systemFontOfSize:12] withText:@"winnumber" withColor:[UIColor lightGrayColor] wihtAlignemt:NSTextAlignmentLeft];
        
        UILabel *hitRedLabel = [self setuplabelwithfont:[UIFont systemFontOfSize:12] withText:@"当期中奖号码 蓝球:" withColor:[UIColor lightGrayColor] wihtAlignemt:NSTextAlignmentLeft];
        self.hitRedTextLabel = [self setuplabelwithfont:[UIFont systemFontOfSize:12] withText:@"winrefernumber" withColor:[UIColor lightGrayColor] wihtAlignemt:NSTextAlignmentLeft];
        
        
        
        [self.contentView addSubview:nameLabel];
        [self.contentView addSubview:noLabel];
        [self.contentView addSubview:dateLabel];
        
        [self.contentView addSubview:realRestLabel];
        [self.contentView addSubview:lotteryRestLabel];
        [self.contentView addSubview:inMoneyLabel];
        
        [self.contentView addSubview:redLabel];
        [self.contentView addSubview:blueLabel];
        [self.contentView addSubview:hitRedLabel];
        [self.contentView addSubview:self.nameTextLabel];
        [self.contentView addSubview:self.noTextLabel];
        [self.contentView addSubview: self.dateTextLabel];
        [self.contentView addSubview:self.realResTextLabel];
        [self.contentView addSubview:self.lotteryResTextLabel];
        [self.contentView addSubview: self.inMoneyTextLabel];
        [self.contentView addSubview:self.redTextLabel];
        [self.contentView addSubview:self.blueTextLabel];
        [self.contentView addSubview: self.hitRedTextLabel];
        
        //1
        [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.contentView).mas_offset(10);
            make.left.equalTo(self.contentView).mas_offset(20);
        }];
        
        [self.nameTextLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(nameLabel.mas_top).mas_offset(0);
            make.left.equalTo(nameLabel.mas_right).mas_offset(10);
        }];
        
        [realRestLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(nameLabel.mas_top).mas_offset(0);
            make.left.equalTo(self.contentView.mas_centerX).mas_offset(10);
        }];
        
        [self.realResTextLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(realRestLabel.mas_top);
            make.left.equalTo(realRestLabel.mas_right).mas_offset(10);
        }];
        
        
        //2.
        [noLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(nameLabel.mas_bottom).mas_offset(10);
            make.left.equalTo(nameLabel.mas_left).mas_offset(0);
            
        }];

        [self.noTextLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(noLabel.mas_top).mas_offset(0);
            make.left.equalTo(noLabel.mas_right).mas_offset(10);
        }];

        [dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(noLabel.mas_top).mas_offset(0);
            make.left.equalTo(self.contentView.mas_centerX).mas_offset(10);
        }];

        [self.dateTextLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(dateLabel.mas_top).mas_offset(0);
            make.left.equalTo(dateLabel.mas_right).mas_offset(10);
        }];
        
        
//        //3.
        [lotteryRestLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(noLabel.mas_bottom).mas_offset(10);
            make.left.equalTo(noLabel.mas_left).mas_offset(0);
        }];

        [self.lotteryResTextLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(lotteryRestLabel.mas_top);
            make.left.equalTo(lotteryRestLabel.mas_right).mas_offset(5);
        }];

        [inMoneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
           make.top.equalTo(lotteryRestLabel.mas_top);
            make.left.equalTo(self.lotteryResTextLabel.mas_right).mas_offset(10);
        }];

        [self.inMoneyTextLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(lotteryRestLabel.mas_top);
            make.left.equalTo(inMoneyLabel.mas_right).mas_offset(5);
        }];

        [redLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(lotteryRestLabel.mas_top);
            make.left.equalTo(self.inMoneyTextLabel.mas_right).mas_offset(10);
        }];

        [self.redTextLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(lotteryRestLabel.mas_top);
            make.left.equalTo(redLabel.mas_right).mas_offset(10);
        }];

        //
        [blueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(lotteryRestLabel.mas_bottom).mas_offset(10);
            make.left.equalTo(lotteryRestLabel.mas_left);

        }];

        [self.blueTextLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(blueLabel.mas_top);
            make.left.equalTo(blueLabel.mas_right).mas_offset(10);
        }];

        //
        [hitRedLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(blueLabel.mas_bottom).mas_offset(10);
            make.left.equalTo(blueLabel.mas_left).mas_offset(0);
            make.bottom.equalTo(self.contentView.mas_bottom).mas_offset(-20);
        }];

        [self.hitRedTextLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(hitRedLabel.mas_top);
            make.left.equalTo(hitRedLabel.mas_right).mas_offset(10);
        }];
        
    }
    return self;
}

-(void)setModel:(LZSCaipiaowinningModel *)model{
    _model = model;
    
    self.nameTextLabel.text = model.number;
    self.noTextLabel.text = model.refernumber;
    self.dateTextLabel.text = model.issueno;
    if ([model.winstatus isEqualToString:@"0"]) {
        self.realResTextLabel.text = @"中奖";
    }else{
        self.realResTextLabel.text = @"未中奖";
    }
    self.lotteryResTextLabel.text = model.prizename?model.prizename:@"暂无";
    self.inMoneyTextLabel.text = model.require?model.require:@"暂无";
    self.redTextLabel.text = model.singlebonus?model.singlebonus:@"暂无";
    self.blueTextLabel.text = model.winnumber?model.winnumber:@"暂无";
    self.hitRedTextLabel.text = model.winrefernumber?model.winrefernumber:@"暂无";
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
